<?php
require_once '../class/control.class.php';
if($_GET['editar']){
	$obj = new Control('consultar','imagens_cases',$_GET['editar']);
	$obj->Consult();
	$con = $obj->result->lista;
}
?>
<div id="load"><img src="images/wait.gif" /></div>
<div><span id="efeito" >Cadastrar</span>
	<div id="box1">
		<form method="post" id="formImagens_cases" enctype="multipart/form-data" >
			<table width="80%" border="0" cellspacing="5" cellpadding="0" align="center">
				<tr>
					<td>Case:</td>
					<td>
						<select name="idcases" id="idcases" class="input" >
							<?php 
								$lst = new Control('dropdown','cases','');
								$lst->Dropdown(); 
							?>
						</select>
					</td>
					<td></td>
				</tr>	
				<tr>
					<td>Imagem:</td>
					<td><input name="imagem0" id="imagem0" type="file" class="input" /></td>
					<td></td>
				</tr>
				<tr>
					<td>Destaque:</td>
					<td>
						<select name="destaque" id="destaque" class="input" >
							<option value="1">Sim</option>
							<option value="0">Não</option>
						</select>
					</td>
					<td></td>
				</tr>
				<tr align="right">
					<td colspan="3">					
						<input type="hidden" name="pagina" 	id="pagina" value="Imagens_cases" />
						<?php 
						if($_GET['editar']){
							echo '<input type="hidden" name="acao" 		id="acao" 		value="update" />';
							echo '<input type="hidden" name="idimagens_cases"	id="idimagens_cases"	value="',$_GET['editar'],'" />';
						}else{
							echo '<input type="hidden" name="acao" id="acao" value="insert" />';
						}
						?>	
						<input type="submit" value="<?php echo $_GET['editar'] ? 'Atualizar' : 'Cadastrar'; ?>" />
					</td>
				</tr>
			</table>
		</form>
	</div>
	<span id="efeito" >Listar / Excluir Cadastrados</span>
	<div id="box2">
		<b>Clique sobre o cabeçalho das colunas para ordenar</b><br />
		<table id="tableOne" class="yui">
			<thead>
				<tr>
					<th>Imagem</th>
					<th>Case</th>
					<th>&nbsp;</th>
					<th>&nbsp;</th>
				</tr>
			</thead>
			<tbody>
				<?php
					$lst = new Control('listar','imagens_cases','');
					$lst->Lister();
					echo $lst->result->lista;
				?>
			</tbody>
		</table>
	</div>
	<script type="text/javascript"> 		
        $(document).ready(function() { 
        	var options = { 
        			beforeSubmit:  loading,
        		    success:    sucesso,
        		    url:    '../class/server.php'
        		};
            $('#formImagens_cases').ajaxForm(options);
            $("#tableOne").tablesorter({ sortList: [[0, 0,]], widgets: ['zebra'] });
            <?php if($_GET['editar']){ ?>
	        	var idedita = '<?php echo $con['idcases']; ?>';
	        	var ideditb = '<?php echo $con['destaque']; ?>';
				$('select#idcases option[value="'+idedita+'"]').attr('selected','selected');
				$('select#destaque option[value="'+ideditb+'"]').attr('selected','selected');
	   		<?php } ?>
        });      
    </script>
</div>